﻿#pragma once

#include "Ability/Group/EditorAbilityGroupViewModel.h"
#include "Math/Color.h"
#include "EditorDebugAndRunAbilityGroupModel.h"
#include "EditorDebugAndRunAbilityGroupViewModel.m.h"

class RTexture2D;
class REditorDebugAndRunAbilityGroupModel;
class RWindow;

RCLASS()
class REditorDebugAndRunAbilityGroupViewModel : public REditorAbilityGroupViewModel
{
    ROBJECT

public:

    void BindModel(TSharedObjectPtr<REditorAbilityModel> InModel) override;
    TSharedObjectPtr<RTexture2D> GetIcon() const override;
    TSharedObjectPtr<RTexture2D> GetHighlightIcon() const override;

protected:

    TWeakObjectPtr<REditorDebugAndRunAbilityGroupModel> Model;
    
    TSharedObjectPtr<RTexture2D> Icon;
    TSharedObjectPtr<RTexture2D> HighlightIcon;

public:
    TSharedObjectPtr<RTexture2D> StartDebugIcon;
    TSharedObjectPtr<RTexture2D> CompileIcon;

    void StartDebug();
    void Compile();

    bool GetDebuggingBarVisible();
    float GetDebugBarInitialX(TSharedObjectPtr<RWindow> InWindow);
    float GetDebugBarInitialY();
    float GetDebugBarMaxX(TSharedObjectPtr<RWindow> InWindow);
    const float MaxDebugBarY = 100.0f;
public:
    TSharedObjectPtr<RTexture2D> GetContinuePauseIcon() const;
    CString GetContinuePauseToolTip() const;

    void OnContinuePauseClicked();
    void StopDebug();

    const float DebugBarHeight = 30.0f;
    const float DebugBarWidth = 200.0f;
    const SColor DebugBarColor = SColor::FromHexRGB(0x181818);
    const SColor DebugBarBorderColor = SColor::FromHexRGB(0x313131);
    const float DebugBarRadius = 5.0f;
    const float DebugBarLeftPadding = 5.0f;
    const float DebugBarRightPadding = 5.0f;
    const float DebugBarGripSize = 25.0f;

    TSharedObjectPtr<RTexture2D> GripIcon;
    TSharedObjectPtr<RTexture2D> ContinueIcon;
    TSharedObjectPtr<RTexture2D> StopIcon;
    TSharedObjectPtr<RTexture2D> StepOverIcon;
    TSharedObjectPtr<RTexture2D> StepIntoIcon;
    TSharedObjectPtr<RTexture2D> StepOutIcon;
    TSharedObjectPtr<RTexture2D> RestartIcon;
    TSharedObjectPtr<RTexture2D> PauseIcon;

public:

    CString GetCurrentConfigurationName() const;
    void SetCurrentConfigurationName(CString InName);
    TVector<CString> GetConfigurationNames() const;

    uint16_t GetPort() const;
    void SetPort(uint16_t InPort);

protected:


    
    CString ToConfigurationName(EDebugConfiguration InConfiguration) const;

};